package icu.guodapeng.oauth2.controller

import com.nimbusds.jose.jwk.JWKSet
import com.nimbusds.jose.jwk.RSAKey
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import java.security.KeyPair
import java.security.interfaces.RSAPublicKey
import javax.annotation.Resource


@RestController
class KeyPairController {
    @Resource
    lateinit var keyPair: KeyPair

    // 获取 RSA 公钥接口
    @GetMapping("/rsa/publicKey")
    fun getKet(): Map<String, Any> = JWKSet(RSAKey.Builder(keyPair.public as RSAPublicKey).build()).toJSONObject()
}
